package com.interview.ThreadTest;

/**
 * date:
 * description:
 */
public class SecondThreadTest implements Runnable {
    volatile int i = 0;

    //重写run方法，run方法的方法体就是现场执行体
    public void run(){
        for(; i < 10; i++){
            System.out.println(Thread.currentThread().getName() + "  " + i);
        }
    }

    public static void main(String[] args){
        for(int i = 0; i < 10; i++){
            System.out.println(Thread.currentThread().getName()+"  : "+i);
            if(i == 2){
                SecondThreadTest rtt = new SecondThreadTest();
                new Thread(rtt,"新线程1").start();
                new Thread(rtt,"新线程2").start();
            }
        }
    }
}
